import router from "@src/router";
import { refundDetail } from "@src/api/reservation";
import { storeBindingsBehavior } from "mobx-miniprogram-bindings";
import reservation from "@src/store/reservation";
Page({
  behaviors: [storeBindingsBehavior],
  storeBindings: [
    {
      store: reservation,
      fields: ["goodsInfo"],
      actions: ["setSubmitGoodsInfo"],
    },
  ],
  data: {
    detailInfo: {},
  },
  onLoad: function (options) {
    this.setData({
      options,
    });
    this.fetchData();
  },
  async fetchData() {
    const { orderNo } = this.data.options;
    refundDetail({
      orderNo,
    })
      .then((res) => {
        const { code, data } = res;
        if (code === 0) {
          this.setData({
            detailInfo: data,
          });
        }
      })
      .catch((err) => {
        console.log("退款错误", err);
        setTimeout(() => {
          wx.navigateBack();
        }, 1000);
      });
  },
});
